﻿using System;
using System.Collections.Generic;
using System.Linq;
using System.Text;

namespace JV.MVVM {
    public class Command: CommandBase {

        Func<object, bool> canExec;
        Action<object> exec;

        public Command( Action<object> Exec ) {
            exec = Exec;
        }

        public Command( Action<object> Exec, Func<object, bool> CanExec ) {
            exec = Exec;
            canExec = CanExec;
        }

        public override bool CanExecute( object parameter ) {
            if ( canExec != null ) return canExec( parameter );
            return true;
        }

        public override void Execute( object parameter ) {
            if ( exec != null ) exec( parameter );
        }

        public void OnCanExecuteChanged( ) {
            base.OnCanExecuteChanged( this );
        }

    }

}
